# -*- coding: utf-8 -*-
"""
Module Description: 
Time : 2021/2/20 
Author : sxj
File : cross_clearance.py
"""
from pyshare.game_logs.cross_clearance_log import CrossClearanceVitLog
from pyshare.const.enums.cross_clearance_enum import NormalNeedVit


class CrossClearanceMiXin(object):

    role_guid = NotImplemented
    vit = NotImplemented

    def role_vit_log(self, val):
        """
        体力日志
        :param val:
        :return:
        """
        add_vit = val - self.vit.remaining
        if add_vit == 0:
            # 无变动
            return

        try:
            if add_vit < 0:
                # 消耗体力
                remark = '普通场消耗体力' if abs(add_vit) == NormalNeedVit else '高级场消耗体力'
                CrossClearanceVitLog.log_game(self.role_guid, val, add_vit, remark=remark)
            else:
                # 增加体力在购买体力接口记入
                remark = '增加体力'
        except:
            pass
